package com.qf.springcloud.filter;

import com.netflix.zuul.ZuulFilter;
import com.netflix.zuul.exception.ZuulException;
import org.springframework.cloud.netflix.zuul.filters.support.FilterConstants;
import org.springframework.stereotype.Component;

@Component
public class TestZuulFilter extends ZuulFilter {

    @Override
    public String filterType() {
        // 设置过滤器类型,   代表前置过滤器
        return FilterConstants.PRE_TYPE;
    }

    @Override
    public int filterOrder() {
        // 设置过滤器的执行顺序
        return FilterConstants.SEND_FORWARD_FILTER_ORDER - 100;
    }

    @Override
    public boolean shouldFilter() {
        // 过滤器的开关
        return true;   // 代表开启
    }

    @Override
    public Object run() throws ZuulException {
        // 执行的业务代码
        System.out.println("执行了TestZuulFilter!!!!");
        return null;   // 返回结果暂时没有任何意义!!!    goto
    }
}
